{% extends "index.html" %}
{% load ifpermit %}

{% block mainmenu %}
<div class="button" onclick="javascript:document.location='/'">News</div>
<div class="button" onclick="javascript:document.location='/folders'">Folders</div>
<div class="button" onclick="javascript:document.location='/groups'">Groups</div>
<div class="button" onclick="javascript:document.location='/search'">Search</div>
<div class="button" onclick="javascript:document.location='/profile'">Profile</div>
<div class="button" onclick="javascript:document.location='/logout'">Logout</div>
{% endblock %}

{% block rightpart %}
<div class="folderheader">Group '{{group.title}}' topics</div>
<div class="rightmenu" onclick="javascript:document.location='/group/{{group.id}}/topics';">All</div>
{% for p in topics %}
<div id="opentopic{{p.id}}" class="rightmenu" onclick="javascript:document.location='/group/{{group.id}}/topic/{{p.id}}';">{{p.title}}</div>
{% endfor %}
{% endblock %}

{% block leftpart %}
<div class="folderbody" id="topicbody{{topic.id}}">

<div class="folderheader" id="topicheader{{topic.id}}">
<div class="folderheadertext">{{topic.title}} by {{topic.starter}}</div>
<div class="smallbutton" id="toggletopic{{topic.id}}" onclick="javascript:toggletopic({{topic.id}});">hide</div>
<div class="smallbutton" onclick="javascript:updatetopic({{topic.id}});">update</div>
{% ifpermit rights A %}
<div class="smallbutton" onclick="javascript:cleantopic({{topic.id}});">clean</div>
<div class="smallbutton" onclick="javascript:purgetopic({{topic.id}});">purge</div>
{% endifpermit %}
</div>

{% for c in topic.comment_set.all %}
<div class="entry">
<div style="display:table-cell;width:100%;"><a href="about:none" onclick="javascript:$('.leftpart').load('/group/{{topic.group.id}}/user/{{c.author.id}}')">{{ c.author.username }}</a></div>
<div class="timestamp" style="display:table-cell;white-space: nowrap;">{{c.created|date}} {{c.created|time}}</div>
{% comment %}
<div id="carma{{c.id}}" style="display:table-cell;white-space: nowrap;">{{c.carma}}<a>+</a>/<a>-</a></div>
{% endcomment %}
{% autoescape off %}
<p>{{c.text}}</p>
{% endautoescape %}
</div>
{% endfor %}
<div class="entry" id="div_comment_add{{topic.id}}">
<div style="display:table-cell;width:100%;">Add your comment</div>
<textarea id="comment_text{{topic.id}}" wrap="virtual" cols="100" rows="3" style='width: 80%'>Enter your comment...</textarea>
<br />
<button onclick="javascript:group_addcomment({{group.id}},{{topic.id}},$('#comment_text{{topic.id}}').attr('value'))">Post</button>
</div>

</div>
{% endblock%}